package com.wish.system.api.factory;

import com.wish.common.core.domain.R;
import com.wish.common.core.web.page.TableDataInfo;
import com.wish.system.api.RemoteHourseService;
import com.wish.system.api.RemoteUserService;
import com.wish.system.api.domain.House;
import com.wish.system.api.domain.SysUser;
import com.wish.system.api.model.LoginUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;

/**
 * 用户服务降级处理
 *
 * @author wish
 */
@Component
public class RemoteHouseFallbackFactory implements FallbackFactory<RemoteHourseService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteHouseFallbackFactory.class);

    @Override
    public RemoteHourseService create(Throwable throwable)
    {
        log.error("房源服务调用失败:{}", throwable.getMessage());
        return new RemoteHourseService()
        {
            @Override
            public TableDataInfo list() {
                return new TableDataInfo();
            }

            @Override
            public R<House> getHouseById(Integer id) {
                return R.fail("获取房源失败:" + throwable.getMessage());
            }

            @Override
            public void bulkIndex() {
                log.error("es全量同步失败:{}");
            }

        };
    }
}
